package cn.xyy.common.domain.system.auth;

import cn.xyy.common.annotation.jdbc.Column;
import cn.xyy.common.annotation.jdbc.Table;
import cn.xyy.common.domain.mvc.BaseEntity;

import java.util.List;

/**
 * 数据字典表
 * 
 * @author xyy
 *
 */
@Table("t_sys_dict")
public class Dict extends BaseEntity implements Comparable<Dict> {

	@Column(value = "dict_id", primaryKey = true)
	private String id; // 字典id

	@Column("dict_name")
	private String name;//

	@Column("parent_id")
	private String parentId;

	@Column("sorts")
	private Integer sorts;// 排序

	// 子
	private List<Dict> children;

	public boolean isRoot() {
		if ("0".equals(this.parentId)) {
			return true;
		}
		return false;
	}

	public String getId() {
		return id;
	}

	public Dict setId(String id) {
		this.id = id;
		return this;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getParentId() {
		return parentId;
	}

	public void setParentId(String parentId) {
		this.parentId = parentId;
	}

	public Integer getSorts() {
		return sorts;
	}

	public void setSorts(Integer sorts) {
		this.sorts = sorts;
	}

	public List<Dict> getChildren() {
		return children;
	}

	public void setChildren(List<Dict> children) {
		this.children = children;
	}

	@Override
	public int compareTo(Dict o) {
		if (this.getSorts() != null && o.getSorts() != null) {
			return this.getSorts().compareTo(o.getSorts());
		}
		return -1;
	}
}
